package com.example.backend.service.mysql.permission.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.backend.entitly.mysql.permission.RolePermissions;
import com.example.backend.mapper.mysql.permission.RolePermissionsMapper;
import com.example.backend.service.mysql.permission.RolePermissionsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 1
 * @description 针对表【role_permissions(角色权限关联表)】的数据库操作Service实现
 * @createDate 2025-06-04 09:01:52
 */
@Service
public class RolePermissionsServiceImpl extends ServiceImpl<RolePermissionsMapper, RolePermissions>
        implements RolePermissionsService {

    @Override
    public List<Integer> getByRoleId(Integer roleId) {
        return new LambdaQueryChainWrapper<>(getBaseMapper())
                .eq(RolePermissions::getRoleId, roleId)
                .list().stream().map(RolePermissions::getPermissionId).collect(Collectors.toList());
    }
}




